<?php

class Ajax_ProductImagesController extends Model3_Controller
{

    public function init()
    {
        $this->view->setUseTemplate(false);
    }
    
    public function indexAction()
    {
        $credentials = Model3_Auth::getCredentials();
        $dbs = Model3_Registry::getInstance()->get('databases');
        $em = $dbs['DefaultDb'];
        /* @var $em Doctrine\ORM\EntityManager */
        
        if($this->getRequest()->isPost())
        {
            $productImagesRepos = $em->getRepository('DefaultDb_Entities_ProductImages');
            $post = $this->getRequest()->getPost();
            $idProduct = $post['idProduct'];
            $images = $productImagesRepos->findBy(array('product' => $idProduct));
            $this->view->images = $images;
        }
    }
}